﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Empires.CRL.Tools
{
    public class CommonRegexpLib
    {
        /// <summary>
        /// ^[\\w\\.]*$
        /// </summary>
        public const string stringValidAllowEmpty = "^[\\w\\.]*$";
        public static string StringValidAllowEmpty { get { return stringValidAllowEmpty; } }
        /// <summary>
        /// 常规字符串验证，"^\\w+$"
        /// </summary>
        public const string stringValid = "^\\w+$";
        /// <summary>
        /// 常规字符串验证，只允许出现A-Za-z0-9@_与汉字至少一次
        /// </summary>
        public static string StringValid { get { return stringValid; } }

        /// <summary>
        /// 在常规字符串验证的基础上添加对‘,（逗号）’与‘;（分号）’的允许"^[\\w\\,;]+$"
        /// </summary>
        public const string stringValid2 = "^[\\w\\,;]+$";
        /// <summary>
        /// 在常规字符串验证的基础上添加对‘,（逗号）’与‘;（分号）’的允许
        /// </summary>
        public static string StringValid2 { get { return stringValid2; } }

        /// <summary>
        /// 在常规字符串验证的基础上添加对‘\s,（空格）’与‘-（横杠）’的允许，出现任意多次"^[\\w\\s\\-]{0,}$"
        /// </summary>
        public const string stringValid3 = "^[\\w\\s\\-]{0,}$";
        /// <summary>
        /// 在常规字符串验证的基础上添加对‘\s,（空格）’与‘-（横杠）’的允许，出现任意多次
        /// </summary>
        public static string StringValid3 { get { return stringValid3; } }

        /// <summary>
        /// 只允许出现0-9的数字，出现任意次"^\\d{0,}$"
        /// </summary>
        public const string integrated = "^\\d{0,}$";
        /// <summary>
        /// 只允许出现0-9的数字，出现任意次
        /// </summary>
        public static string Integrated { get { return integrated; } }

        /// <summary>
        /// 只允许出现0-9的数字，出现至少一次"^\\d+$"
        /// </summary>
        public const string integrated1 = "^\\d+$";
        /// <summary>
        /// 只允许出现0-9的数字，出现至少一次
        /// </summary>
        public static string Integrated1 { get { return integrated1; } }

        public const string email = "^[a-zA-Z0-9_\\.\\-]+\\@(([a-zA-Z0-9\\-])+\\.)+([a-zA-Z0-9]{2,4})+$";
        public static string Email { get { return email; } }

        /// <summary>
        /// 非空"^.+$"
        /// </summary>
        public const string notEmpty = "^.+$";
        public static string NotEmpty { get { return notEmpty; } }

        /// <summary>
        /// 匹配jpg或png格式图片\\w+\\.((jpg)|(png))$
        /// </summary>
        public const string isJPGorPNG = "\\w+\\.((jpg)|(png))$";
        public static string IsJPGorPNG { get { return isJPGorPNG; } }

        /// <summary>
        /// 匹配扩展名,分组名：ext
        /// </summary>
        public const string getExtendName = ".+\\.(?<ext>\\w+)$";
        /// <summary>
        /// 匹配扩展名,分组名：ext
        /// </summary>
        public static string GetExtendName { get { return getExtendName; } }

        private const string customerName = "[^\\w]";
        /// <summary>
        /// 匹配非\w
        /// </summary>
        public static string CustomerName { get { return customerName; } }
        /// <summary>
        /// 提取img标签的src
        /// </summary>
        private const string pickImgLabForSrc = "(?<=<img.*?src=\").*?(?=\")";
        public static string PickImgLabForSrc { get { return pickImgLabForSrc; } }
        /// <summary>
        /// 匹配电话号码（手机或者座机）
        /// </summary>
        public const string matchPhone="^(\\+8)?1\\d{10}$|^((0\\d{2,3})-)?(\\d{7,8})(-(\\d{3,}))?$";
        public static string MatchPhone { get { return matchPhone; } }
    }
}
